// pages/home/home.js
Page({

  data: {
    messageList:[],
  },

  //------------------ 页面数据加载模块 start---------------------------
  onLoad:function(){
    this.getAllMessage();  // 加载考研资讯/考研热点
    
  },
  // 当点击首页时，重新刷新首页
  onTabItemTap(item) {
    console.log(item);
    this.getAllMessage();
  },
  //------------------ 页面数据加载模块 end---------------------------


  //------------------功能模块 start----------------------
  // 获取考研资讯/考研热点数据
  getAllMessage:function(){
    var mark = 'getAllMessage';
    wx.request({
      url: 'http://localhost:8080/youYanZaiXian/MessageServlet',
      method: 'POST',
      data:{
        mark:mark,
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
      },
      success: (res)=>{
        var messageList = res.data.data.messageList;
        this.setData({
          messageList:messageList,
        })
        //console.log(this.data.messageList)
      }
    });
  },

  //------------------功能模块 end----------------------

  // ----------------页面跳转功能块 start--------------------------------
  enterColloge:function(e){
    wx.navigateTo({
      url: '/pages/college/college',
    })
  },
  enterMessage:function(e){
    wx.navigateTo({
      url: '/pages/message/message',
    })
  },
  // 跳转到考研全知道
  enterAllKnow:function(e){
    wx.navigateTo({
      url: '/pages/allKnow/allKnow',
    })
  },
  // 跳转到国家线
  enterNationalLine:function(e){
    wx.navigateTo({
      url: '/pages/nationalLine/nationalLine',
    })
  },
  // 进入考研热点详情
  goMcontent:function(e){
    var mid = e.currentTarget.dataset.mid;
    var userid = e.currentTarget.dataset.userid;
    wx.navigateTo({
      url: '/pages/message/mContent/mContent?mid='+mid+'&userid='+userid,
    })
  }
  // ----------------页面跳转功能块 end--------------------------------
})


/***
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */